import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import 'package:honeypotflutter/publicBussine/bussine_font.dart';
import 'package:honeypotflutter/publicBussine/bussine_image.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_card.dart';
import '../pages/hire_rent_rent/logic.dart';

class HireRentRentDayPage extends StatefulWidget {
  const HireRentRentDayPage({Key? key}) : super(key: key);

  @override
  State<HireRentRentDayPage> createState() => _HireRentRentDayPageState();
}

class _HireRentRentDayPageState extends State<HireRentRentDayPage> {
  final HireRentRentLogic logic = Get.find<HireRentRentLogic>();

  List<int> days = [6, 14, 30];

  @override
  Widget build(BuildContext context) {
    return MGCard(
      margin: EdgeInsets.only(top: 16, bottom: 16),
      padding: EdgeInsets.only(top: 12, bottom: 12),
      children: days
          .map((e) => ListTile(
                title: Text("租用${e}天",
                    style: TextStyle(
                      color: MGColors.text1Color,
                      fontSize: MGFont.textFont1,
                      fontWeight: FontWeight.bold,
                    )),
                subtitle: Text("${logic.startTime} - ${logic.calculateDate(e)}",
                    style: TextStyle(
                      color: MGColors.text3Color,
                      fontSize: MGFont.textFont2,
                    )),
                trailing: Obx(() => Image.asset(
                      (logic.selectDay.value == e) ? MGImage.image("public_pass") : MGImage.image("public_no_pass"),
                      width: 23,
                    )),
                onTap: () {
                  logic.selectDay.value = e;
                  logic.updateCountPrice();
                },
              ))
          .toList(),
    );
  }

  @override
  void dispose() {
    super.dispose();
  }
}
